<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>登录—注册页面 | </title>

    <!-- Bootstrap -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="css/font-awesome.min.css" rel="stylesheet">
    <!-- NProgress -->
    <!--<link href="css/nprogress.css" rel="stylesheet">-->
    <!-- Animate.css -->
    <link href="css/animate.min.css" rel="stylesheet">
    <link href="css/button.css" rel="stylesheet">

    <!-- Custom Theme Style -->
    <link href="css/custom.min.css" rel="stylesheet">
</head>

<body class="login">
<div>
    <a class="hiddenanchor" id="signup"></a>
    <a class="hiddenanchor" id="signin"></a>

    <div class="login_wrapper">
        <div class="animate form login_form">
            <section class="login_content">
                <form>
                    <h1>GLS国际物流系统 </h1>
                    <div>
                        <input type="text" class="form-control" placeholder="用户名" id="userName" required="" />
                    </div>
                    <div>
                        <input type="password" class="form-control" id="pwd" placeholder="密&nbsp;&nbsp;&nbsp;码" required="" /><span style="color:red;" id="span2"></span>
                    </div>
                    <div>
                        <a class="btn btn-default submit" id="login" href="javascript:;">登 录</a>
                        <a class="btn btn-default submit" href="misspwd.html">忘记密码</a>
                    </div>

                    <div class="clearfix"></div>

                    <div class="separator">
                        <p class="change_link">网站新手?
                            <a href="#signup" class="to_register"> 创建账号</a>
                        </p>

                        <div class="clearfix"></div>
                        <br />

                        <div>
                            <h1><i class="fa fa-paw"></i> 美的&nbsp;&nbsp;&nbsp;集团</h1>
                            <p>©2019 All Rights Reserved. </p>
                        </div>
                    </div>
                </form>
            </section>
        </div>

        <div id="register" class="animate form registration_form">
            <section class="login_content">
                <form action="index.html">
                    <h1>注册账号</h1>

                    <div>
                        <input type="text" class="form-control" placeholder="用&nbsp;&nbsp;户&nbsp;&nbsp;名"  />
                    </div>
                    <div>
                        <input type="password" class="form-control" placeholder="密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码" required="" />
                    </div>
                    <div>
                        <input type="password" class="form-control" placeholder="请确认密码" required="" />
                    </div>
                    <div>
                        <input type="text" class="form-control" placeholder="手机号码" required="" />
                    </div>
                    <div style="margin-top: 20px;margin-bottom: 20px;">
                        <input type="text" class="form-control" placeholder="请输入手机验证码" required="" style="width: 180px;margin: 0;display: inline-block;"/>
                        <button type="buttonlw" id="button1lw">获取验证码</button>
                    </div>

                    <div>
                        <button class="btn btn-default submit" 	>注册</button>
                        <button class="btn btn-default submit" type="reset">重置</button>
                    </div>

                    <div class="clearfix"></div>

                    <div class="separator">
                        <p class="change_link">已有账号 ?
                            <a href="#signin" class="to_register"> 登录 </a>
                        </p>

                        <div class="clearfix"></div>
                        <br />

                        <div>
                            <h1><i class="fa fa-paw"></i>美的&nbsp;&nbsp;&nbsp;集团</h1>
                            <p>©2019 All Rights Reserved. </p>
                        </div>
                    </div>
                </form>
            </section>
        </div>
    </div>
</div>
</body>
<script src="js/jquery.min.js"></script>
<script>
    $(function  () {
        $("#login").click(function() {
            var $userName=$("#userName").val();
            var $pwd=$("#pwd").val();
            if($userName==0||$userName.length==0){
                $("#span2").html("用户名不能为空");
            }else if($userName.length<5||$userName.length>12){
                $("#span2").html("用户名必须在5-12之间");
            }else{
                if($pwd==0||$pwd.length==0){
                    $("#span2").html("密码不能为空");
                }else if($pwd.length<6||$pwd.length>12){
                    $("#span2").html("密码必须在6-15之间");
                }else{
                    $.ajax({
                        type:"post",
                        url:"http://localhost:8081/first/login",
                        dataType:"json",
                        data:{"userName":$userName,"pwd":$pwd},
                        xhrFields: {withCredentials: true},
                        success:function(data) {
//              	document.cookie="token="+data.map['token']+";expires=Session";

                            if(data.message=="yes"){
                                window.sessionStorage.setItem('token',data.map['token']);
                                location.href=("index.html");

                            }else if(data.message=="nopwd"){
                                $("#span2").html("密码错误");
                                $("#userName").val($userName);
                                $("#pwd").val($pwd);
                            }else{
                                $("#span2").html("用户名不存在");
                                $("#userName").val($userName);
                                $("#pwd").val($pwd);
                            }
                        },
                        error:function(){i
                            alert("错误");
                        }
                    });
                }}

        })

    })
</script>
</html>